/**
 * 
 */
package com.autoreassociate;

import com.autoreassociate.tool.ConnectionAssociateTool;

import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.PreferenceActivity;

/**
 * @author UserXP
 *
 */
public class SettingActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
	
	
	public final static String NAME = "setting";
	

	
	public final static String BROADCAST_AUTO_START_SERVICE_WHEN_WIFI_ON = "broadcast_auto_start_service_when_wifi_on";
	
	public final static String BROADCAST_WIFI_DISCONNECT_RSSI_STRENGTH = "broadcast_wifi_disconnect_rssi_strength";

	public final static String TOAST_VIEW_TOAST_MESSAGE = "toast_view_toast_message";
	
	public final static String NOTI_VIEW_NOTI_MESSAGE = "noti_view_noti_message";
	
	public final static String BROADCAST_REASSOCIATE_WHEN_SCREEN_ON = "broadcast_reassociate_when_screen_on";
	
	public final static String BROADCAST_AUTO_WIFI_TURN_OFF_TIME = "broadcast_auto_wifi_turn_off_time";
	
	public final static String BROADCAST_AUTO_WIFI_TURN_ON_CHECK_TIME = "broadcast_auto_wifi_turn_on_check_time";
	
	/** 부팅시 자동시작 프로퍼티 */
	public final static String BROADCAST_AUTO_START_WHEN_BOOT_UP = "broadcast_auto_start_when_boot_up";
	
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // Load the preferences from an XML resource
        addPreferencesFromResource(R.xml.setting_preference);
        getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
        
        //logTool(getPreferenceScreen().get);
        
    }

    
    
    @Override
    protected void onResume() {
    	super.onResume();
    }
    

    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {

    	
    	//if (key.equals("broadcast_auto_wifi_turn_on_check_time")) {
    		//String a = sharedPreferences.getString("broadcast_auto_wifi_turn_on_check_time", "ccc");
    		//ConnectionAssociateTool.getInstance().getMessageLogManager().printVT("sssssssss  " + key);
    	//}
    	
    	

    }

    @Override
    protected void onStop() {
    	super.onStop();
    	//MainActivity.printVT("onStop");
    	//sendBroadcast(CatchWifiRequest.REQUEST_RESET_INTENT);
    	if (ConnectionAssociateTool.getInstance() != null) {
    		ConnectionAssociateTool.getInstance().restartWifiStatusReceiver();
    	}
    }
    

    @Override
    protected void onPause() {
    	super.onPause();
    	
    	if (!isFinishing()) {
    		//sendBroadcast(ConnectionCheckReceiver.REQUEST_RESET_INTENT);
    		ConnectionAssociateTool.getInstance().attributesReset();
    		
    	}
    }
}
